﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DTO;
using BUS;

namespace QuanLyCongDoanVien.UserControls
{
    public partial class ucHuyTaiKhoan : UserControl
    {
        public ucHuyTaiKhoan()
        {
            InitializeComponent();
        }

        private void btnHuy_Click(object sender, EventArgs e)
        {
            NguoiDungDTO nguoiDungDto = new NguoiDungDTO();
            nguoiDungDto = (NguoiDungDTO)cboTenNguoiDung.SelectedItem;
            try
            {
                NguoiDungBUS.XoaNguoiDung(nguoiDungDto.TenNguoiDung);
                MessageBox.Show("Đã xóa tài khoản " + nguoiDungDto.TenNguoiDung);
                ucHuyTaiKhoan_Load(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void ucHuyTaiKhoan_Load(object sender, EventArgs e)
        {
            try
            {                
                cboTenNguoiDung.DataSource = NguoiDungBUS.LayDanhSach();
                cboTenNguoiDung.DisplayMember = "TenNguoiDung";
                cboTenNguoiDung.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
